
/*
 * @author Adley, Butcher, and Sanders
 * CSC 285 Final Project
 */

package tetris;

import java.awt.Color;

/**
 * Enum containing the basic shapes used by the game. 
 * Double boolean array. First dimension is simply the rotation of the shape.
 * Second dimension contains the 16 booleans used to draw the shape by the
 * program proper. They are organized so that the shape is always spawned
 * with the top flush with the top of the board.
 * Color is the color of the shape.
 * 
 */
public enum TileShape {

    /**
     * The I tetrimino.
     */
    ShapeI(Color.CYAN,new boolean[][]{
                {
			false,	false,	true,	false,
			false,	false,	true,	false,
			false,	false,	true,	false,
			false,	false,	true,	false
		},
		{
			false,	false,	false,	false,
			false,	false,	false,	false,
			true,	true,	true,	true,
			false,	false,	false,	false
		},
		{
			false,	true,	false,	false,
			false,	true,	false,	false,
			false,	true,	false,	false,
			false,	true,	false,	false
		},
{
			false,	false,	false,	false,
			true,	true,	true,	true,
			false,	false,	false,	false,
			false,	false,	false,	false
		}
	}),

    /**
     * The J tetrimino.
     */
    ShapeJ(Color.GRAY,new boolean[][] {
		{   
			true,	false,	false, false,
			true,	true,	true,  false,
			false,  false,	false, false,
                        false,  false,  false, false
		},
		{
			false,	true,	true,  false,
			false,	true,	false, false,
			false,	true,	false, false,
                        false,  false,  false, false
		},
		{
			false,	false,	false, false,
			true,	true,	true,  false,
			false,	false,	true,  false,
                        false,  false,  false, false
		},
		{
			false,	true,	false, false,
			false,	true,	false, false,
			true,	true,	false, false,
                        false,  false,  false, false
		}
	}),

    /**
     * The L tetrimino.
     */
    ShapeL(Color.ORANGE, new boolean[][] {
		{ 
			false,	false,	true,  false,
			true,	true,	true,  false,
			false,	false,	false, false,
                        false,  false,  false, false
		},
		{
			false,	true,	false, false,
			false,	true,	false, false,
			false,	true,	true,  false,
                        false,  false,  false, false
		},
		{
			false,	false,	false, false,
			true,	true,	true,  false,
			true,	false,	false, false,
                        false,  false,  false, false
		},
		{
			true,	true,	false, false,
			false,	true,	false, false,
			false,	true,	false, false,
                        false,  false,  false, false
		}
	}),

    /**
     * The O tetrimino.
     */
    ShapeO(Color.YELLOW, new boolean[][] {
		{  
                        false, true,  true,  false,
			false, true,  true,  false,
                        false, false, false, false,
			false, false, false, false
		},
		{
                        false, true,  true,  false,
			false, true,  true,  false,
                        false, false, false, false,
			false, false, false, false
		},
		{	
                        false, true,  true,  false,
			false, true,  true,  false,
                        false, false, false, false,
			false, false, false, false
		},
		{
                        false, true,  true,  false,
			false, true,  true,  false,
                        false, false, false, false,
			false, false, false, false
		}
	}),

    /**
     * The S tetrimino.
     */
    ShapeS(Color.BLUE,new boolean[][] {
		{   
			false,	true,	true,  false,
			true,	true,	false, false,
			false,	false,	false, false,
                        false,  false,  false, false
		},
		{
			false,	true,	false, false,
			false,	true,	true,  false,
			false,	false,	true,  false,
                        false,  false,  false, false
		},
		{
			false,	false,	false, false,
			false,	true,	true,  false,
			true,	true,	false, false,
                        false,  false,  false, false
		},
		{
			true,	false,	false, false,
			true,	true,	false, false, 
			false,	true,	false, false,
                        false,  false,  false, false
		}
	}),

    /**
     * The T tetrimino.
     */
    ShapeT(Color.RED, new boolean[][] {
		{  
			false,	true,	false, false,
			true,	true,	true,  false,
			false,	false,	false, false,
                        false,  false,  false, false
		},
		{
			false,	true,	false, false,
			false,	true,	true,  false,
			false,	true,	false, false,
                        false,  false,  false, false
		},
		{
			false,	false,	false, false,
			true,	true,	true,  false,
			false,	true,	false, false,
                        false,  false,  false, false
		},
		{
			false,	true,	false, false,
			true,	true,	false, false,
			false,	true,	false, false,
                        false,  false,  false, false
		}
	}),

    /**
     * The Z tetrimino.
     */
    ShapeZ(Color.GREEN,new boolean[][] {
		{
                        false,	false,	true,  false,
			false,	true,	true,  false,
			false,	true,	false, false,
                        false,  false,  false, false
		},
		{
                        false,	false,	false, false,
			true,	true,	false, false,
			false,	true,	true,  false,
                        false,  false,  false, false
		},
		{
                        false,	true,	false, false,
			true,	true,	false, false,
			true,	false,	false, false,
                        false,  false,  false, false
		},
                {  
			false,  false,  false, false,
			true,	true,	false, false,
			false,	true,	true,  false,
                        false,	false,	false, false
		}
	});

/**
 * Holds the tiles.
 * @param col The color of the shape
 * @param squares The individual squares in the shape
 */
	private final boolean[][] squares;
        private final Color col;
        

        private TileShape(Color color, boolean[][] tiles) {
                this.col = color;
		this.squares = tiles;
	}
        
        
	
	/**
	 * Checks to see if the given coordinates and rotation contain a tile.
         * Only checks one tile.
	 * @param x The x coordinate of the tile.
	 * @param y The y coordinate of the tile.
	 * @param rotation The rotation to check in.
	 * @return Whether or not a tile resides there.
	 */
	public boolean tileCheck(int rotation, int x, int y) {
		return squares[rotation][y * 4 + x];
	}

        // Returns the shape's squares
        
        public boolean[][] getShape(){
            return squares;
}
	public Color getColor(){
            return col;
        }
}
